package com.foreveredu.propms.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * Description:<br/>
 * 领域模型：楼栋类，一个小区包含多个楼栋<br/>
 * Date:<br/>
 * 2013/3/2<br/>
 * 
 * @author hushigang
 */

@Entity
@Table(name = "T_Building")
public class Building implements Serializable {

	private static final long serialVersionUID = 1L;
	private int id;
	private String buildingId;// 楼栋编号
	private String name;// 楼栋名称
	private BuildingType type;// 楼栋类型，包括多层、高层
	private int floorCount;// 楼层总数
	private SubDistrict subDistrict;// 所属小区
	private Set<House> houses = new HashSet<House>();//楼栋包含的所有房产（双向一对多关系）

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column
	public String getBuildingId() {
		return buildingId;
	}

	public void setBuildingId(String buildingId) {
		this.buildingId = buildingId;
	}

	@Column
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column
	public int getFloorCount() {
		return floorCount;
	}

	public void setFloorCount(int floorCount) {
		this.floorCount = floorCount;
	}

	@ManyToOne
	@JoinColumn(name = "subDistrict_id")
	public SubDistrict getSubDistrict() {
		return subDistrict;
	}

	public void setSubDistrict(SubDistrict subDistrict) {
		this.subDistrict = subDistrict;
	}

	@ManyToOne
	@JoinColumn(name = "buildingType_id")
	public BuildingType getType() {
		return type;
	}

	public void setType(BuildingType type) {
		this.type = type;
	}

	@OneToMany(mappedBy="building")
	@OrderBy(value="id ASC")
	public Set<House> getHouses() {
		return houses;
	}

	public void setHouses(Set<House> houses) {
		this.houses = houses;
	}

}
